package com.dfbz.demo01_抽象类小案例;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo01 {
    public static void main(String[] args) {

        // 抽象类不可以实例化
//        Employee employee=new Employee();
//        employee.work();

        Cook cook=new Cook();
        cook.setId("001");
        cook.setName("小红");
        cook.setSalary(20000.0D);
        cook.work();

        System.out.println("----------------");

        Security security=new Security();
        security.setId("002");
        security.setName("小刚");
        security.setSalary(30000.0D);
        security.work();

    }

}

// 员工类
abstract class Employee {
    private String id;
    private String name;
    private double salary;

    // 抽象方法,每个员工都有方法,那么具体的方法内容是什么,父类不能说清楚,留给子类说(这个方法是留给子类来重写的)
    public abstract void work() ;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }
}

// 含有抽象方法的类必须是抽象类
class Cook extends Employee {
    public void work() {
        System.out.println("炒菜...");
    }
}

class Security extends Employee {
    public void work() {
        System.out.println("检查外来人员..");
    }
}

class Cleaner extends Employee {
    public void work() {
        System.out.println("负责公司清洁");
    }
}